//
// Created by RandBII on 2020/12/28.
//

#include "GLHelper.h"


GLuint GLHelper::LoadShader(GLenum shaderType, const char *pSource) {
    return 0;
}

GLuint GLHelper::CreateProgram(const char *pVertexShaderSource, const char *pFragmentShaderSource,
                               GLuint &vertexShaderHandle, GLuint &fragmentShaderHandle) {
    return 0;
}

GLuint GLHelper::CreateProgram(const char *pVertexShaderSource, const char *pFragmentShaderSource) {
    return 0;
}

GLuint GLHelper::CreateProgramWithCallBack(const char *pVertexShaderSource,
                                           const char *pFragmentShaderSource,
                                           GLuint &vertexShaderHandle,
                                           GLuint &fragmentShaderHandle,
                                           const GLchar **varying, int varyingCount) {
    return 0;
}

void GLHelper::DeleteProgram(GLuint &program) {

}

void GLHelper::CheckGLError(const char *pGLOperation) {

}

void GLHelper::SetBool(GLuint programId, const std::string &name, bool value) {
    glUniform1i(glGetUniformLocation(programId, name.c_str()), (int) value);
}

void GLHelper::SetInt(GLuint programId, const std::string &name, int value) {
    glUniform1i(glGetUniformLocation(programId, name.c_str()), value);
}

void GLHelper::SetFloat(GLuint programId, const std::string &name, float value) {
    glUniform1f(glGetUniformLocation(programId, name.c_str()), value);
}

void GLHelper::SetVec2(GLuint programId, const std::string &name, const glm::vec2 &value) {
    glUniform2fv(glGetUniformLocation(programId, name.c_str()), 1, &value[0]);
}

void GLHelper::SetVec2(GLuint programId, const std::string &name, float x, float y) {
    glUniform2f(glGetUniformLocation(programId, name.c_str()), x, y);
}

void GLHelper::SetVec3(GLuint programId, const std::string &name, float x, float y, float z) {
    glUniform3f(glGetUniformLocation(programId, name.c_str()), x, y, z);
}

void GLHelper::SetVec3(GLuint programId, const std::string &name, const glm::vec3 &value) {
    glUniform3fv(glGetUniformLocation(programId, name.c_str()), 1, &value[0]);
}

void GLHelper::SetVec4(GLuint programId, const std::string &name, const glm::vec4 &value) {
    glUniform4fv(glGetUniformLocation(programId, name.c_str()), 1, &value[0]);
}

void
GLHelper::SetVec4(GLuint programId, const std::string &name, float x, float y, float z, float w) {
    glUniform4f(glGetUniformLocation(programId, name.c_str()), x, y, z, w);
}

void GLHelper::SetMat2(GLuint programId, const std::string &name, const glm::mat2 &mat2) {
    glUniformMatrix2fv(glGetUniformLocation(programId, name.c_str()), 1, GL_FALSE, &mat2[0][0]);
}

void GLHelper::SetMat3(GLuint programId, const std::string &name, const glm::mat3 &mat3) {
    glUniformMatrix3fv(glGetUniformLocation(programId, name.c_str()), 1, GL_FALSE, &mat3[0][0]);
}

void GLHelper::SetMat4(GLuint programId, const std::string &name, const glm::mat4 &mat4) {
    glUniformMatrix4fv(glGetUniformLocation(programId, name.c_str()), 1, GL_FALSE, &mat4[0][0]);
}

glm::vec3 GLHelper::textCoordToVertexCoord(glm::vec2 texCoord) {
    return glm::vec3(2 * texCoord.x - 1, 1 - 2 * texCoord.y, 0);
}















